/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2021-2022. All rights reserved.
 */

import { isWindows } from '@ohos/hvigor';
import { Component } from '@ohos/sdkmanager-common';
import path from 'path';

import { HosSdkComponent } from '../superior/hos-sdk-component.js';

/**
 * sdk java实例
 */
export class SdkJavaComponent extends HosSdkComponent {
  private static readonly LIB = 'lib';
  private static readonly API = 'api';
  private static readonly BUILD_TOOLS = 'build-tools';
  private static readonly OHOS_JAR = 'ohos.jar';
  private static readonly ABILITY_SHELL_JAR = 'abilityshell_ide_java.jar';
  private static readonly ACE_IDE_JAR = 'ace_ide_java.jar';

  constructor(component: Component) {
    super(component, 'java');
  }

  public getRestoolPath(): string {
    const resTool = isWindows() ? 'restool.exe' : 'restool';
    return path.resolve(this.getBaseDir(), SdkJavaComponent.BUILD_TOOLS, resTool);
  }

  public getOhosJarPath(): string {
    return path.resolve(this.getBaseDir(), SdkJavaComponent.API, SdkJavaComponent.OHOS_JAR);
  }

  public getAbilityShellJarPath(): string {
    return path.resolve(this.getBaseDir(), SdkJavaComponent.API, SdkJavaComponent.ABILITY_SHELL_JAR);
  }

  public getAceJarPath(): string {
    return path.resolve(this.getBaseDir(), SdkJavaComponent.API, SdkJavaComponent.ACE_IDE_JAR);
  }

  public getReleaseType(): string {
    return this.getComponent().getReleaseType();
  }
}
